import commonList from '@/components/common/commonList'
import cLabel from "@/components/cat-label/cat-label.vue"
export default {

	data() {
		return {
			Inv: 0,
			// 新增
			num: 0,
			// 未提交数组
			tableData: [],
			userInfo: {},
			fCheckStatus: "", //一级0，二级1，三级2
			flagNum: -1,
			selectList: null,
			// 
			table_config: [{
					label: "设备号",
					prop: "equipmentNumber",
					isLine: false,

				},
				{
					label: "闭合状态",
					prop: "fClosestatus",
					isLine: false,
				},
				{
					label: "预警级别",
					prop: "fWarninglevel",
					isLine: true,
				},

				{
					label: "有效桩长(m)",
					prop: "syxzc",
					isLine: true,
				}, {
					label: "开始时间",
					prop: "startdates",
					isLine: true,
				},
				{
					label: '结束时间',
					prop: 'enddates',
					isLine: true,
				}
			],
		}
	},
	components: {
		commonList,
		cLabel
	},
	onShow() {
		var that = this
		if (this.Inv == 0) {
			setTimeout(() => {
				that.unsubmit()
			}, 300)
		}
		if (this.Inv == 1) {
			setTimeout(() => {
				that.submit()
			}, 300)
		}

	},
	onLoad(option) {
		var that = this
		if (option.Inv) {
			this.Inv = option.Inv
		}
		this.getLocalData()
	},
	// 新增
	onNavigationBarButtonTap(e) {
		if (e.index === 0) {
			var url = "/pages/apply/softFoundationManage/overLimitMonitor/inter/index"
			uni.navigateTo({
				url: url
			});
		}
	},
	// 返回
	onBackPress(event) {
		uni.switchTab({
			url: '/pages/home/index'
		});
		return true;
	},

	methods: {
		getEquipmentData(obj) {
			this.selectList = []
			this.$http.getEquipmentList(obj)
				.then((res) => {

					if (res.errcode == 0) {
						if (res.data.pageInfo.list.length > 0) {
							res.data.pageInfo.list.map((item) => {
								this.selectList.push(item.equipmentNumber);
							});
							this.fCheckStatus =
								res.data.pageInfo.list[0].equipmentNumber;
							this.flagNum = 0
						} else {
							this.selectList = []
							this.fCheckStatus = ""
						}


						this.yj_searchForm(this.getList); // 调用主页面列表接口
						// that.tableData = res.data.pageInfo.list;
						// this.queryCriteriaData = res.data.pageInfo;
					} else {
						this.$message.error("列表数据获取失败", res.msg);
						this.loading = false;
					}
				})
				.catch((error) => {
					this.$message.error("列表数据 接口出错", error.msg);
					this.loading = false;
				});
		},
		// 查看
		yj_viewForm(e) {
			// console.log();
			// if (e.Inv == 0) {
				if(JSON.parse(e.item).fCloseoperation=="未闭合"||JSON.parse(e.item).fCloseoperation=="已闭合"){
						uni.navigateTo({
							url: "/pages/apply/softFoundationManage/overLimitMonitor/inter/index?id=" + e.id + "&fId=" +
								e.item
						});
						return false;
				}else {
					uni.showToast({
						title: "当前数据不能处理",
						icon: 'none',
						duration: 2000
					});
				}
			
			// }
			// if (e.Inv == 1) {
			// 	uni.navigateTo({
			// 		url: "/pages/apply/softFoundationManage/overLimitMonitor/submit/index?id=" + e.id
			// 	});
			// 	return false;
			// }

		},
		submit() {
			var that = this
			this.Inv = 1
			this.yj_searchForm(this.Inv)
		},
		unsubmit() {
			var that = this
			this.Inv = 0
			this.yj_searchForm(this.Inv)
		},

		getLocalData() {
			var that = this
			uni.getStorage({
				key: 'userInfo',
				success: function(res) {
					that.userInfo = JSON.parse(res.data)
					that.companyId = that.userInfo.companyId;
					// that.getEquipmentData({
					// 	fCompanyid: that.userInfo.companyId
					// });

				}
			})
		},
		callback() {},
		// 获取列表
		yj_searchForm(num) {
			var that = this
			num = num.toString()
			var datas = {
				// fCheckStatus: "", //一级0，二级1，三级2
				fCompanyid: that.userInfo.companyId, // 左侧选中组织机构id
				equipmentNumber: "", //设备识别号
				warningLevel: "", //预警等级
				fCloseoperation: "", //闭合状态
				page: 1, // 当前页码
				pageSize: 40, // 每页显示条数
				startDates: "", //开始时间
				endDates: "" ,//结束时间
				// modelType:num
			}
			
			this.$http.getMixingPileAlertList(datas).then(res => {
				if (res.errcode == 0) {
					console.log(res, 22);
					that.tableData = []
					that.tableData = res.data.pageInfo.list;
			
				} else {
					console.log("接口报错")
				}
			}, (err) => {
				uni.showToast({
					title: "获取数据失败",
					icon: 'none',
					duration: 2000
				});
			})
			// this.$http.getMixingPileAlertByEN({
			// 		fCompanyid: that.userInfo.companyId,
			// 		fEquipmentnumber: this.fCheckStatus
			// 	})
			// 	.then((res) => {
			// 		console.log(res);
			// 		if (res.errcode == 0) {
			// 			// console.log(111, res.data.data.fAduituser1.split("-"));
			// 			var arr = res.data.data.fAduituser1.split("-");
			// 			console.log(arr,this.userInfo.companyNature);
			// 			arr.map((item, index) => {
			// 				if (item == this.userInfo.companyNature) {
			// 					datas.fCheckStatus = index.toString();
			// 				}
			// 			})


					
			// 		}
			// 	})
			// 	.catch((error) => {
			// 		console.log(error);
			// 	});


		}


	}
}
